package org.jeecg.glr.service.impl;

import org.jeecg.glr.entity.GlrPatternGateway;
import org.jeecg.glr.mapper.GlrPatternGatewayMapper;
import org.jeecg.glr.service.IGlrPatternGatewayService;
import org.jeecg.glr.util.GLRConstant;
import org.jeecg.glr.util.StringUtil;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 网关模式关联表
 * @Author: jeecg-boot
 * @Date:   2020-03-10
 * @Version: V1.0
 */
@Service
public class GlrPatternGatewayServiceImpl extends ServiceImpl<GlrPatternGatewayMapper, GlrPatternGateway> implements IGlrPatternGatewayService {

    @Resource GlrPatternGatewayMapper glrPatternGatewayMapper;


    @Override
    public void bingPattern(GlrPatternGateway glrPatternGateway) {
        if(StringUtil.isNotEmpty(glrPatternGateway.getIds())){
            String[] strids=glrPatternGateway.getIds().split(",");
            for (String id :
                    strids) {
                GlrPatternGateway domain = new GlrPatternGateway();
                domain.setPatternId(id);
                domain.setType(glrPatternGateway.getType());
                domain.setCurrentStatus(GLRConstant.YN_N);
                domain.setGateWayCode(glrPatternGateway.getGateWayCode());
                super.save(domain);
            }
        }

    }

    @Override
    public List<String> getPatternByGateWayCode(String patternId,String type) {
        return glrPatternGatewayMapper.getPatternByGateWayCode(patternId,type);
    }

    @Override
    public void bingPatternGateWay(GlrPatternGateway glrPatternGateway) {
        if(StringUtil.isNotEmpty(glrPatternGateway.getIds())){
            String[] strids=glrPatternGateway.getIds().split(",");
            for (String id :
                    strids) {
                GlrPatternGateway domain = new GlrPatternGateway();
                domain.setPatternId(glrPatternGateway.getPatternId());
                domain.setType(glrPatternGateway.getType());
                domain.setCurrentStatus(GLRConstant.YN_N);
                domain.setGateWayCode(id);
                super.save(domain);
            }
        }
    }
}
